package org.grow.util.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

/**
 * @Author: xwg
 * @CreateDate: 2022/5/30
 */

@RestController
@RequestMapping("/util/codeGenerator")
public class CodeGeneratorController {

    private Random random = new Random();
    @Value("${server.port}")
    private Integer port;

    @GetMapping("/nextCode")
    public String nextCode(@RequestParam String prefix) {
        return (prefix.toUpperCase() + System.currentTimeMillis()) + random.nextInt(10) + ": " + port;
    }
}
